home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 November / PCWNOV08.iso / Software / Freeware / NoteTab Light 5.7 / NoteTab_Setup.exe / {app} / Libraries / SampleCode.clb < prev    next >
Encoding:
Text File  |  2008-07-15  |  21.6 KB  |  611 lines

  1. = V5 MultiLine NoSorting TabWidth=30
  2.  
  3. H=";About this library"
  4. This library was written by Fookes Software to serve as a demonstration of the varied tasks that can be performed by the Editor Clipbook. It contains various items that illustrate how certain Clip commands and functions can be used. Most of these Clips do not really provide useful functions, but they can help you understand how to create your own Clips. We recommend that you look at the Clip code and compare it with what happens when you activate it.
  5.  
  6.  
  7. H=";"
  8.  
  9.  
  10. H=";Launching Programs"
  11.  
  12.  
  13. H="Batch example"
  14. ^!Continue This Clip will first launch the Windows calculator; once you close it, MS Wordpad will be opened. Continue?
  15. ;Launches the calculator utility and waits until the user closes it
  16. ^!ShellWait calc.exe
  17. ;Launches the Wordpad program
  18. ^!Shell Wordpad.exe ^$GetShort("^##")$
  19.  
  20. H="Shortcut example"
  21. ;Executes application associated with the shortcut
  22. ^!Prompt This Clip example will only work if you have a shortcut labeled "Explorer" pointing to Windows Explorer on your Desktop.
  23. ^!Shell ^$GetShellFolder(Desktop)$explorer.lnk
  24.  
  25. H="Send E-Mail"
  26. ;Demonstrates the ^!EMail command
  27. ^!EMail ^?[E-mail address];^?[E-mail subject=^&]^?[Copy text from active document to E-mail body?=_Yes^=;+|No^=;]
  28.  
  29. H="Launch Document"
  30. ;Opens the current document in its associated application (for example .html file opens in default browser). A temporary copy of the document is made if it wasn't saved before using the "^**" instruction
  31. ^!Shell "^**"
  32.  
  33. H=";"
  34.  
  35.  
  36. H=";Updating INI options"
  37.  
  38.  
  39. H="1. ProgIniSave"
  40. ;Saves current settings to the "Test.ini" file in the NoteTab program directory (default when no path is specified)
  41. ^!ProgIniSave Test.ini
  42.  
  43. H="2. ProgIniEdit"
  44. ;Check if the file "Test.ini" exists. If it does, skip the next instruction, otherwise create it and save the NoteTab settings to it
  45. ^!IfFileExist ^$GetDataPath$Test.ini Skip
  46. ;Saves current settings to the "Test.ini" file in the NoteTab program directory (default when no path is specified)
  47. ^!ProgIniSave Test.ini
  48. ;Open the "Test.ini" file in NoteTab
  49. ^!Open ^$GetDataPath$Test.ini
  50. ;Show message
  51. ^!Prompt Edit items in the Test.ini file, save the changes, and then activate on the Clip "3. ProgIniLoad" to update NoteTab option settings
  52.  
  53. H="3. ProgIniLoad"
  54. ;Update NoteTab settings with options contained in the "Test.ini" file
  55. ^!ProgIniLoad Test.ini
  56.  
  57. H=";"
  58.  
  59.  
  60. H=";Scripts"
  61.  
  62.  
  63. H="Perl script"
  64. ;Check if a Perl interpreter has been setup. If not, jump to the label NoPerl
  65. ^!IfFileExist ^$GetPerlExe$ Next ELSE NoPerl
  66. ;Delete the file "StdError.err" from the NoteTab program directory, if it exists
  67. ^!DeleteFile ^$GetDataPath$StdError.err
  68. ;Execute the Perl interpreter with the script contained in the Clip labeled "NumLines"
  69. ^!RunPerl Perl NumLines
  70. ;If the interpreter generated error messages, load them from the file "StdError.err" 
  71. ^!IfFileExist ^$GetDataPath$StdError.err Next ELSE End
  72. ^!Open ^$GetDataPath$StdError.err
  73. ^!Prompt Perl has reported some errors!
  74. ^!GoTo End
  75. :NoPerl
  76. ^!Prompt Cannot execute this Clip without a Perl interpreter!
  77.  
  78.  
  79. H="Gawk scripts"
  80. ;Thanks to Wayne M. VanWeerthuizen for the GAWK samples used by this Clip!
  81. ;Check if a Gawk interpreter has been setup. If not, jump to the label Error
  82. ^!IfFileExist ^$GetGawkExe$ Next ELSE Error
  83. ;Prompt user for the script to use with the Gawk interpreter and save answer in a variable
  84. ^!Set %ScriptName%=^?{(T=C)Choose GAWK script to modify document==_Reverse|Add Spaces}
  85. ;Abort this procedure if the Clip wizard was cancelled by the user
  86. ^!IfCancel Exit
  87. ;Execute the Gawk interpreter with the chosen script
  88. ^!RunGawk ^%ScriptName%
  89. ^!GoTo End
  90. :Error
  91. ^!Prompt Cannot execute this Clip without a GAWK interpreter!
  92.  
  93.  
  94. H="_Reverse"
  95. # Reverse text
  96. BEGIN { FS = "" }
  97. {
  98. for (i=NF;i>0;i--) printf("%s",$i);
  99. printf("\n");
  100. }
  101.  
  102.  
  103.  
  104. H="_Add Spaces"
  105. # Add spaces
  106. BEGIN { FS = "" }
  107. {
  108. for (i=1;i<NF;i++) printf("%s ",$i);
  109. printf("%s\n",$NF);
  110. }
  111.  
  112.  
  113.  
  114. H="_Perl NumLines"
  115. #
  116. #รก \perl\numline.pl
  117. #
  118. # begin
  119. while (<>) {
  120.     $x=sprintf("%05d",$.);
  121.     print "$x $_";
  122. }
  123. # end
  124.  
  125.  
  126. H=";"
  127.  
  128.  
  129. H=";Keyboard Macros"
  130.  
  131.  
  132. H="Show text statistics"
  133. ;Press key combination Alt+T, followed by the letter S, followed by a delay of 400 milliseconds to give the dialog box time to open, followed by the letter M
  134. ^!Keyboard ALT+T S &400 M
  135.  
  136. H="Open AutoExec.bat"
  137. ;Set delay of approximately 200 milliseconds between each keystroke
  138. ^!KeyboardDelay 200
  139. ;Press key combination Ctrl+O (opens the File Open dialog box), followed by the text "c:\autoexec.bat", followed by the Enter key (to close the dialog box)
  140. ^!Keyboard CTRL+O #c:\autoexec.bat# ENTER
  141.  
  142. H="Use Windows Calculator"
  143. ;The following script shows how you can send keys to another program
  144.  
  145. ;Check if the calculator program is open. Jumpt to BringToFront label if found
  146. ^!IfAppOpen Calculator BringToFront ELSE Next
  147. ;Calculator program was not open, so now we launch it
  148. ^!Shell Calc.exe
  149. ;give it enough time to load (4/10th of a second)
  150. ^!Delay 4
  151.  
  152. :BringToFront
  153. ;Bring Calculator program to the front
  154. ^!FocusApp Calculator
  155.  
  156. :PressKeys
  157. ;Add all numbers from 1 to 9 and then activate the equal button with the ENTER key
  158. ;Set delay of approximately 200 milliseconds between each keystroke
  159. ^!KeyboardDelay 200
  160. ;Send keystrokes to the calculator utility
  161. ^!Keyboard #1+2+3+4+5+6+7+8+9# ENTER
  162.  
  163.  
  164. H=";"
  165.  
  166.  
  167. H=";Wizard Fields"
  168.  
  169.  
  170. H="Remember variable"
  171. ;Show message
  172. ^!Info This Clip shows you how variables can be used in the Clip wizard and reused as default values in the dialog box's fields. The value of the variables will be inserted into the current document (unless you cancel the Clip wizard). The Clip wizard will be displayed repeatedly until you click on the Cancel button.
  173. ;Place cursor at the end of the document
  174. ^!Jump TEXT_END
  175.  
  176. :StartLoop
  177. ;Show Clip wizard with two fields. Each receives the default value contained in the variable following the label's equal sign
  178. ^!Set %p_FName%=^?{First Name=^%p_FName%}; %p_LName%=^?{Last Name=^%p_LName%}
  179. ;Abort this procedure if the Clip wizard was cancelled by the user
  180. ^!IfCancel Exit
  181. ;Insert text and variable content into document
  182. First Name: ^%p_FName%
  183. Last Name:  ^%p_LName%
  184.  
  185.  
  186. ;Jump back to the start of the loop
  187. ^!Goto StartLoop
  188.  
  189. H="Remember default value"
  190. ;Create a new document
  191. ^!ToolBar New Document
  192.  
  193. ;If the variable ValueList is not empty, skip the next instruction
  194. ^!IfFalse ^$IsEmpty(^%ValueList%)$ Skip
  195. ;Assign a list of values to the variable ValueList
  196. ^!Set %ValueList%=_1|2|3|4|5|6
  197.  
  198. ;Beginning of loop
  199. :StartLoop
  200. ;Promp user to select a value from the list in the Clip wizard
  201. ^!Set %DefaultValue%=^?{Choose or enter a new default value=^%ValueList%}
  202. ;Insert the chosen value in the document, followed by a line break
  203. ^!SetPasteIndent Off
  204. ^!InsertText Default value = ^%DefaultValue%^p
  205. ;Change the default-value marker to match the item chosen by the user
  206. ^!Set %ValueList%=^$SetDefaultValue(^%ValueList%;^%DefaultValue%)$
  207. ;Prompt user to continue or end Clip
  208. ^!Continue Continue demonstration?
  209. ;Jump back to the start of the loop
  210. ^!Goto StartLoop
  211.  
  212. H="Play sound"
  213. ;Show Clip wizard with choice of system sounds, then play chosen sound. Some of these sounds may not work under Windows XP.
  214. ^!Sound ^?[Play Sound=SystemAsterisk|_SystemExclamation|SystemHand|SystemQuestion|SystemDefault]
  215.  
  216. H="Open multiple files"
  217. ;Sample code for displaying a Clip wizard with a File Open field "T=O", with possibility of selecting multiple files "S=M"
  218. ^!Open ^?[(T=O;S=M;F="Text Files (*.txt;*.ini)|*.txt;*.ini")Prompt]
  219.  
  220. H="Insert HRef link"
  221. ;Sample code for displaying a Clip wizard with a URL-tag field (T=T), and file filters matching HTML documents
  222. ^!InsertHtml <A ^?[(T=T;F="HTML Files|*.*htm*;*.php;*.asp")Link to web page]>^?[Link text=^&]</A>
  223.  
  224. H="Multiple fields"
  225. ;Show message
  226. ^!Continue This Clip will demonstrate various Wizard field types. The resulting output will be inserted into the current document. Continue?
  227. ;Create a new document
  228. ^!ToolBar New Document
  229. ;Display Clip wizard with various types of fields
  230. ^?[(T=W)&Memo Field with word wrap=This default text has^pseveral lines^p thanks to the use of^ptokens]
  231. ^?[&Prompt=List1^=Hello World^PMy name is Paul|List2^=Value2^Twith a tab|List3^=Three^pLines^Pfor you]
  232. ^?[(T=O;F="Text Files|*.txt;*.ini;*.*htm*")&Browse Field #1=c:\Windows\]
  233. <A ^?[(T=T;F="HTML Files|*.*htm*;*.asp;*.css")&Link to web page=c:\html\]>^?[Link &text=^&]</A>
  234. <IMG ^?[(T=T;C=L;F="Image Files|*.gif;*.jpg;*.jpeg")Link to &image=c:\html\] BORDER=0 ALT="^?[&Alt=^&]">
  235. ^?[(T=M;S=400;H=8)M&emo Field without word wrap]
  236. ^?[(M=">LL00;0;*")Mas&k Field]
  237.  
  238.  
  239. H="Insert file"
  240. ;Sample Clip demonstrating a prompt for inserting a file in the current document
  241. ^!InsertFile ^?{(T=O;F="Text Files|*.txt;*.ini;*.*htm*")Enter file name to insert=^$GetWinPath$}
  242.  
  243. H=";"
  244.  
  245.  
  246. H=";Arrays and Checkboxes"
  247.  
  248.  
  249. H="SetArray demo 1"
  250. ;Assign semicolon-delimited values to array variable
  251. ^!SetArray %Month%=January;February;March;April;May;June;July;August;September;October;November;December
  252. ;Prompt user to choose a month number
  253. ^!Set %MonthId%=^?[Choose a month number (1..12)=4]
  254. ;Show info window with month name corresponding to user's choice. The content of the array's indexed variable is used here
  255. ^!Info Month (#^%MonthId%) = ^%Month^%MonthId%%
  256.  
  257. H="SetArray demo 2"
  258. ;Assign semicolon-delimited values to array variable
  259. ^!SetArray %Names%=Cindy;Evelyn;Nicole
  260. ;Show content of array variable
  261. ^!Info 1. List of names:^P^P^%Names%
  262. ;Change the content of the second item in the array variable according to the user's input
  263. ^!Set %Names2%=^?{Change name #2=Kay}
  264. ;Show updated content of array variable
  265. ^!Info 2. List of names:^P^P^%Names%
  266.  
  267. H="SetArray demo 3"
  268. ;Assign all the file names chosen by the user into an array variable
  269. ^!SetArray %Files%=^?[(T=O;S=M;F="Text Files (*.txt;*.ini)|*.txt;*.ini")You can select several files]
  270. ;Copy the value representing the number of items into the Count variable. The variable at index 0 indicates the number of items in the array
  271. ^!Set %Count%=^%Files0%
  272. ;Initialize the Index variable to 0
  273. ^!Set %Index%=0
  274.  
  275. ;Beginning of loop
  276. :StartLoop
  277. ;Add one to the value contained in the variable Index
  278. ^!Inc %Index%
  279. ;End the Clip if the Index number is greater than the Count number
  280. ^!If ^%Index% > ^%Count% End
  281. ;Show the file name corresponding to the current index value. The content of the array's indexed variable is used here
  282. ^!Prompt File #^%Index% = ^%Files^%Index%%
  283. ;Jump back to the start of the loop
  284. ^!Goto StartLoop
  285.  
  286. H="SetListDelimiter"
  287. ;Define a list delimiter as two successive line breaks
  288. ^!SetListDelimiter ^p^p
  289. ;Loads all the text in the current document into the array variable. Each section of text separated by a blank line will be stored in its own indexed variable
  290. ^!SetArray %Array%=^$GetText$
  291. ;Prompt the user for a paragraph index number
  292. ^!Set %ParaIndex%=^?[Display paragraph #=4]
  293. ;Display the corresponding paragraph text in an info window
  294. ^!Info Paragraph (#^%ParaIndex%) = ^%NL%^%Array^%ParaIndex%%
  295.  
  296.  
  297. H=";----"
  298.  
  299.  
  300. H="CheckBoxes demo 1"
  301. ;Display checkbox list with Value2 and Value4 checked by default
  302. ^!Info ^?[(T=A)Prompt=Value1|_CheckedValue2|Value3|_CheckedValue4|Value5]
  303.  
  304. H="CheckBoxes demo 2"
  305. ;Change default delimiter to a blank space
  306. ^!SetListDelimiter " "
  307. ;Display checkbox list with Value2 and Value4 checked by default. The list displays a text that is different from the actual values
  308. ^!Info ^?{(T=A)Prompt=Value1^=V1|_CheckedValue2^=V2|Value3^=V3|_CheckedValue4^=V4|Value5^=V5}
  309.  
  310. H=";"
  311.  
  312.  
  313. H=";Loops"
  314.  
  315.  
  316. H="Loop demo 1"
  317. ;Demonstrates how loops can be created in Clip syntax
  318. ^!Continue This demonstrates Clip looping...
  319. ;Create a new document
  320. ^!ToolBar New Document
  321.  
  322. ;Beginning of loop
  323. :Start
  324. ;Insert text in document
  325. Paste Me!
  326.  
  327. ;Display prompt to user. If user confirms, next instruction is skipped
  328. ^!Skip Paste again?
  329. ;Ends Clip
  330. ^!GoTo End
  331. ;Jump back to the start of the loop
  332. ^!GoTo Start
  333.  
  334. H="Loop demo 2"
  335. ;Demonstrates how loops can be created in Clip syntax
  336. ^!Continue This demonstrates Clip looping...
  337. ;Create a new document
  338. ^!ToolBar New Document
  339. ;Copy value returned by Clip wizard to a variable
  340. ^!Set %Counter%=^?[Repeat count]
  341.  
  342. ;Beginning of loop
  343. :Start
  344. ;Test if value contained in variable is less than 1. End Clip if it is.
  345. ^!If ^%Counter% < 1 End
  346. ;Subtract one from the value contained in the Counter variable
  347. ^!Dec Counter
  348. ;Insert text in document
  349. Paste Me!
  350.  
  351. ;Jump back to the start of the loop
  352. ^!GoTo Start
  353.  
  354. H="Address database"
  355. ;Creates a CSV list of address information
  356. ;Places cursor at the end of the text
  357. ^!Jump TEXT_END
  358.  
  359. ;Beginning of loop
  360. :Start
  361. ;Ask if user wants to add another address. End Clip if not
  362. ^!Continue Add an address?
  363. ;Display Clip wizard with address fields
  364. "^?{First Name}","^?{Last Name}","^?{Address 1}","^?{Address 2}","^?{City}","^?{State/Province}","^?{ZIP/Postal Code}","^?{Country}","^?{Phone}","^?{Fax}"
  365.  
  366. ;Jump back to the start of the loop
  367. ^!Goto Start
  368.  
  369. H="Loop tabs demo 1"
  370. ;Activates the first document in the tab bar
  371. ^!Document First
  372.  
  373. ;Beginning of loop
  374. :Start
  375. ;Ask if user wants to continue Clip
  376. ^!Continue Next document is now current. Continue?
  377. ;Activates the next document in the tab bar
  378. ^!Document Next
  379. ;End Clip if an error condition was generated (i.e. no more documents after the current one)
  380. ^!IfError End
  381. ;Jump back to the start of the loop
  382. ^!GoTo Start
  383.  
  384. H="Loop tabs demo 2"
  385. ;Initialize variable Index to 0
  386. ^!Set %Index%=0
  387.  
  388. ;Beginning of loop
  389. :LoopStart
  390. ;Add one to the value contained in the Index variable
  391. ^!Inc %Index%
  392. ;End Clip if the value contained in Index is greater to the number of open documents
  393. ^!If ^%Index% > ^$GetDocCount$ End
  394. ;Activate the specified document
  395. ^!SetDocIndex ^%Index%
  396. ;Ask if user wants to continue Clip
  397. ^!Continue Document changed (Index = ^%Index%). Continue?
  398. ;Jump back to the start of the loop
  399. ^!GoTo LoopStart
  400.  
  401. H=";"
  402.  
  403.  
  404. H=";Delimited Text"
  405. Demonstrates how NoteTab can be used to search and process text in delimited (tab, comma, or other) data files
  406.  
  407.  
  408. H="Copy field"
  409. ^!Continue This Clip will open a tab-delimited file and select the field that matches the specified coordinates. Continue?
  410. ;Opens file "Data.txt" in the Samples subdirectory
  411. ^!Open ^$GetSamplesPath$Data.txt
  412. ;Prompts user for field index to select, then copies field to the Clipboard
  413. ^!SetClipboard ^$GetField(^?[Row=13];^?[Column=2])$
  414.  
  415. H="Search fields"
  416. ^!Continue This Clip will open a tab-delimited file and select the field that matches the specified search criteria. Continue?
  417. ;Opens file "Data.txt" in the Samples subdirectory
  418. ^!Open ^$GetSamplesPath$Data.txt
  419. ;Copies the line count number to a variable
  420. ^!Set %MaxRow%=^$GetLineCount$
  421. ;Initialize variable Row to 0
  422. ^!Set %Row%=0
  423. ;Prompt user for field delimiter used in document (the sample file Data.txt uses tabs)
  424. ^!SetDelimiter ^?[(6;T=C)Field Delimiter==_Tab^=^%TAB%|Semi-colon^=;|Space^=^%SPACE%|Equal sign^==|SDF^="";""|None^=]
  425.  
  426. ;Beginning of loop
  427. :LoopStart
  428. ;Add one to the value contained in the Index variable
  429. ^!Inc %Row%
  430. ;End Clip if value contained in Row is greater than the value contained in MaxRow (i.e. Number of lines in document)
  431. ^!If ^%Row% > ^%MaxRow% End
  432. ;Prompt user for search criteria and store matched text position in variable
  433. ^!Set %Pos%=^$GetPosInField(^%Row%;^?[(2)Column=2];^?[(3)Whole word=_Yes^=|No^=T]^?[(4)Ignore case=_Yes^=I|No^=]^?[(5)Criteria must match...=Start of field^=S|Whole field^=W|_Any part of field^=];"^?[(1)Search criteria=America]")$
  434. ;If the value stored in Pos is greater than 0 (we have a match), jump to the next instruction otherwise return to start of loop
  435. ^!If ^%Pos% > 0 Next ELSE LoopStart
  436. ;Move the input focus to the current document
  437. ^!FocusDoc
  438.  
  439. H="Copy data column"
  440. ^!Continue This Clip will open a tab-delimited file and copy all the fields from the specified column. Continue?
  441. ;Opens file "Data.txt" in the Samples subdirectory
  442. ^!Open ^$GetSamplesPath$Data.txt
  443. ;Empty the contents of the Column variable
  444. ^!Set %Column%=^%Empty%
  445. ;Copies the line count number to a variable
  446. ^!Set %MaxRow%=^$GetLineCount$
  447. ;Initialize variable Row to 0
  448. ^!Set %Row%=0
  449. ;Prompt user for field delimiter used in document (the sample file Data.txt uses tabs)
  450. ^!SetDelimiter ^?[(2;T=C)Field Delimiter==_Tab^=^%TAB%|Semi-colon^=;|Space^=^%SPACE%|Equal^==|SDF^="";""|None^=]
  451.  
  452. ;Beginning of loop
  453. :LoopStart
  454. ;Add one to the value contained in the Index variable
  455. ^!Inc %Row%
  456. ;End loop if value contained in Row is greater than the value contained in MaxRow (i.e. Number of lines in document)
  457. ^!If ^%Row% > ^%MaxRow% EndLoop
  458. ;Place cursor at beginning of line
  459. ^!SetCursor ^%Row%:1
  460. ;Add field matching the user-chosen column to the Column variable with line break
  461. ^!Set %Column%=^%Column%^$GetField(^?[(1)Column to copy=2])$^%NL%
  462. ;Jump back to the start of the loop
  463. ^!GoTo LoopStart
  464.  
  465. :EndLoop
  466. ;Open a new document
  467. ^!Toolbar New Document
  468. ;Paste contents of the variable into the new document
  469. ^!InsertCode ^%Column%
  470.  
  471. H=";"
  472.  
  473.  
  474. H=";Miscellaneous"
  475.  
  476.  
  477. H="Help on current word"
  478. ;Copy word under cursor into a variable
  479. ^!Set %Word%=^$GetWord$
  480. ;If the variable is empty (i.e. there was no word under the cursor), jump to the label ShowInfo
  481. ^!IfTrue ^$IsEmpty(^%Word%)$ ShowInfo
  482. ;Show topic matching keyword in NoteTab Help file
  483. ^!Help "" ^%Word%
  484. ;End Clip
  485. ^!Goto End
  486. :ShowInfo
  487. ^!Prompt First put the cursor on a word. This Clip will attempt to find a matching topic in the Help file
  488.  
  489. H="Clip Help on current word"
  490. ;Place cursor on Clip command or function and activate this Clip to show Help
  491. ^!Set %Keyword%=^$GetWord$
  492. ^!If "^$StrCopyLeft("^%Keyword%";1)$" <> "$" IsCommand
  493. ^!If "^$StrCopyRight("^%Keyword%";1)$" = "$" ^!Set %Keyword%=^$StrDeleteRight("^%Keyword%";1)$
  494. ^!If "^%Keyword%" = "" Exit
  495. ^!Goto ShowHelp
  496.  
  497. :IsCommand
  498. ^!If "^%Keyword%" = "" Exit
  499. ^!Set %Keyword%=!^%Keyword%
  500.  
  501. :ShowHelp
  502. ^!Help "ClipCode.chm" ^%CARET%^%Keyword%
  503. ^!Keyboard ENTER
  504.  
  505. H="Open HTML template"
  506. ;Opens a template file for the creation of a web page
  507. ^!Open ^$GetTemplatePath$HTML.tpl
  508.  
  509. H="Get DOS output"
  510. ;Displays the output of the chosen DOS command to an info window
  511. ^!Info [L]^$GetDosOutput("^?[Dos output to display in Info window=dir c:\*.*]")$
  512.  
  513. H="Copy outline topics"
  514. ;If the current document is an outline, start the procedure. Otherwise ask whether to demonstrate the feature on the Readme.otl document, which is part of the NoteTab package
  515. ^!IfFalse ^$IsOutlineDoc$ OpenReadme
  516. ;Jump to the Start label
  517. ^!GoTo Start
  518.  
  519. :OpenReadme
  520. ;Open the Readme.otl document
  521. ^!Open ^$GetAppPath$Readme.Otl
  522. ;If there was an error while trying to open it, show message and end procedure
  523. ^!IfError Error
  524.  
  525. :Start
  526. ;Initialize variable TopicIndex to 0
  527. ^!Set %TopicIndex%=0
  528. ;Store the topics count in a variable
  529. ^!Set %TopicCount%=^$GetTopicCount$
  530. ;Empty the content of the Clipboard
  531. ^!SetClipboard ^%Empty%
  532.  
  533. :LoopStart
  534. ;Add one to the value contained in the TopicIndex variable
  535. ^!Inc %TopicIndex%
  536. ;Jump to PasteTopics label if TopicIndex is greater than TopicCount
  537. ^!If ^%TopicIndex% > ^%TopicCount% PasteTopics
  538. ;Make the outline topic that matches the value in TopicIndex active
  539. ^!SetTopicIndex ^%TopicIndex%
  540. ;Add the name of the active outline topic and a line break to the Clipboard
  541. ^!SetClipboard ^$GetClipboard$^$GetTopicName$^%NL%
  542. ;Jump back to the start of the loop
  543. ^!GoTo LoopStart
  544.  
  545. :Error
  546. ;Show error message
  547. ^!Prompt Error: the current document is not an outline
  548. ;End Clip
  549. ^!GoTo End
  550.  
  551. :PasteTopics
  552. ;Paste contents of the Clipboard into a new document
  553. ^!Toolbar Paste New
  554.  
  555. H="Open EBCDIC file"
  556. ;Prompts user to choose an EBCDIC file(s) and opens in NoteTab
  557. ^!OpenEbcdic ^?{(T=O;S=M;F="EBCDIC files (*.cbl;*.cob;*.cpy;*.ddl;*.bms)|*.cbl;*.cob;*.cpy;*.ddl;*.bms")Open EBCDIC file(s)=^$GetSamplesPath$Ebcdic.cob} /W=^?{LRECL=Variable Width^=0|80|_100|132|133}
  558.  
  559. H="Export document"
  560. ;Clip demonstrating the Export command
  561. ^!Export "^?[(T=S;F="Text Files|*.txt;*.ini;*.*htm*")File Name=c:\Temp\]" ^?[Character Set=ASCII|_ANSI] ^?[Format=_PC|MAC|UNIX|EBCDIC] ^?[Text=SELECTION|_ALL] ^?[Hard-break word wrap=_No^= |Yes^=HARDBREAKS]
  562.  
  563. H="NoteTab name and version"
  564. ;Clip functions to extract NoteTab program name and version
  565. ^!Info ^$GetProgName$ (version ^$GetProgVersion$)
  566.  
  567. H="Show paragraph"
  568. ;Demonstrates the GetParagraph function
  569. ^!Info ^$GetParagraph(^?[Display paragraph #=2])$
  570.  
  571. H="Paragraph cursor position"
  572. ^!Info ^$GetParaRow$:^$GetParaCol$
  573.  
  574. H="FarClip demo 1"
  575. ;Demonstrates the FarClip command. This will activate the Clip labeled "Center" in the HTML.clb library file
  576. ^!FarClip HTML:Center
  577.  
  578. H="FarClip demo 2"
  579. ;Demonstrates the FarClip command. This will activate the Clip labeled "Show Date" in the Samples\FarClips.dat library file
  580. ^!FarClip "^$GetSamplesPath$FarClips.dat:"Show Date""
  581.  
  582. H="Set bookmark"
  583. ;Check if editor type is NoteTab Light/Std. If it is, show error message (Bookmarks are only supported in NoteTab Pro)
  584. ^!IfSame ^$GetEditorType$ nts SntError
  585. ;Prompt user for bookmark number and set bookmark accordingly
  586. ^!SetBookmark ^?{Set Bookmark #=_1|2|3|4|5|6|7|8|9|0}
  587. ;Finish the Clip by jumping to the EndClip label
  588. ^!GoTo EndClip
  589.  
  590. :SntError
  591. ^!Prompt Sorry, bookmarks only work with NoteTab Pro!
  592.  
  593. :EndClip
  594. ;Move the input focus to the current document
  595. ^!FocusDoc
  596.  
  597. H="Go to bookmark"
  598. ;Check if editor type is NoteTab Light/Std. If it is, show error message (Bookmarks are only supported in NoteTab Pro)
  599. ^!IfSame ^$GetEditorType$ nts SntError
  600. ;Prompt user for bookmark number and move cursor to it if it exists
  601. ^!GotoBookmark ^?{Go to Bookmark #=_1|2|3|4|5|6|7|8|9|0}
  602. ;Finish the Clip by jumping to the EndClip label
  603. ^!GoTo EndClip
  604.  
  605. :SntError
  606. ^!Prompt Sorry, bookmarks only work with NoteTab Pro!
  607.  
  608. :EndClip
  609. ;Move the input focus to the current document
  610. ^!FocusDoc
  611.